﻿using DBUtil.SqlSegment;

namespace DBUtil.Provider.PostgreSql.SqlSegment;

public class PostgreSqlDateTimeSqlSegment : DateTimeSqlSegment
{
    public PostgreSqlDateTimeSqlSegment(DBAccess db) : base(db)
    {
    }

    public override string Current => "now()";
    public override string DefaultDateTimeType => "timestamp";

    #region 当前时间加上 年/月/天/小时/分钟/秒
    public override string GetCurrentAddYear(int year) => $"now()::timestamp + '{year} year'";
    public override string GetCurrentAddMonth(int month) => $"now()::timestamp + '{month} month'";
    public override string GetCurrentAddDay(int day) => $"now()::timestamp + '{day} day'";
    public override string GetCurrentAddHour(int hour) => $"now()::timestamp + '{hour} hour'";
    public override string GetCurrentAddMinute(int minute) => $"now()::timestamp + '{minute} minute'";
    public override string GetCurrentAddSecond(int second) => $"now()::timestamp + '{second} second'";
    #endregion
}
